<?php

include 'autoload.php';

$id_usuarios = $sessao->getValor('sessao_id_usuarios');
$id_album = (isset($_GET['id_album'])) ? intval($_GET['id_album']) : null;
try{

if (!empty($id_album)) {
    $sql = "SELECT * FROM album WHERE id_album = :id_album";
    $params = array(
        'id_album' => array(
            'valor' => $id_album,
            'pdotype' => PDO::PARAM_INT
        )
    );

    $crud = new SqlCrud();
    $dados = $crud->executaSql($sql, $params);
} else {
    $dados[0] = array(
        'id_album' => null,
        'nome' =>  '',
        'descricao' => '',
        'Ativo' => ''
    );
}
} catch (PDOException $e){
    new Excecao($e);
}
$smarty->assign('dados', $dados[0]);
$smarty->assign('id_usuarios', $id_usuarios);
$smarty->assign('id_album', $id_album);
$smarty->display('cadastra_album.tpl');